//
//  NetWorkNotify.m
//  花花时尚
//
//  Created by 霍文轩 on 15/8/28.
//  Copyright (c) 2015年 霍文轩. All rights reserved.
//

#import "NetWorkNotify.h"

@implementation NetWorkNotify
+(instancetype)showNetworkNotify{
    NetWorkNotify * networkNotify = [[NetWorkNotify alloc] initWithFrame:CGRectMake(0, 0, 200, 50)];
    return [networkNotify autorelease];
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self NetWorkNotifyView];
    }
    return self;
}
-(void)NetWorkNotifyView{
    self.alpha = 0.8;
    self.center = CGPointMake([UIScreen mainScreen].bounds.size.width/2, [UIScreen mainScreen].bounds.size.height/6*5);
    self.backgroundColor = [UIColor blackColor];
    self.layer.cornerRadius = 5;
    
    UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
    label.text = @"请检查网络设置";
    label.textColor = [UIColor whiteColor];
    label.font = [UIFont boldSystemFontOfSize:17];
    label.textAlignment = NSTextAlignmentCenter;
    [self addSubview:label];
    [label release];
    
    [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(disappear:) userInfo:nil repeats:NO];
    
}
-(void)disappear:(NSTimer *)timer{
    [UIView animateWithDuration:0.1 animations:^{
        self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, 0, 0);
        self.alpha = 0;
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];
}
@end
